#include "Gem.h"
#include "..\Engine\Core\Core.h"
#include "..\Engine\Graphics\SpriteManager.h"
#include "SDL.h"


CGem::CGem(EGemType GemType)
	: CObject2D(NULL)	
	, m_bSelected(false)
{
	SetGemType(GemType);
}

void CGem::SetGemType(const EGemType GemType)
{
	m_eGemType = GemType;
	//Set the correct sprite
	std::string SpriteName;
	switch(m_eGemType)
	{
	case GT_RED:
		if (m_bSelected) SpriteName = "sRed.png";
		else SpriteName = "Red.png";
		break;
	case GT_BLUE:		
		if (m_bSelected) SpriteName = "sBlue.png";
		else SpriteName = "Blue.png";
		break;
	case GT_GREEN:		
		if (m_bSelected) SpriteName = "sGreen.png";
		else SpriteName = "Green.png";
		break;
	case GT_PURPLE:		
		if (m_bSelected) SpriteName = "sPurple.png";
		else SpriteName = "Purple.png";
		break;
	case GT_YELLOW:		
		if (m_bSelected) SpriteName = "sYellow.png";
		else SpriteName = "Yellow.png";
		break;
	}
	m_Sprite = CORE.GetSpriteManager()->getResource(SpriteName.c_str());
}

void CGem::SetSelected(const bool Selected)
{
	m_bSelected = Selected;
	SetGemType(GetGemType());//update sprite
}

